package com.fengye.algorithms.huawei;

import java.util.Scanner;

/**
 * https://www.nowcoder.com/practice/54404a78aec1435a81150f15f899417d?tpId=37&tqId=21274&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
 * @Author fengye
 * @Date 2023/4/7 11:00
 **/
public class OneWayListLastNumber {
    static class Node {
        public int mKey;
        public Node next;
        public Node(int mKey) {
            this.mKey = mKey;
        }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int f = in.nextInt();
            Node head = new Node(f);
            Node point = head;
            while (n-- > 1) {
                int m = in.nextInt();
                Node node = new Node(m);
                point.next = node;
                point = node;
            }

            point = head;
            Node pointE = head;
            int w = in.nextInt();
            boolean isNull = false;
            while (w-- > 0) {
                if (pointE != null) {
                    pointE = pointE.next;
                } else {
                    isNull = true;
                }
            }
            if (isNull) {
                System.out.println();
                continue;
            }
            while (pointE != null) {
                pointE = pointE.next;
                point = point.next;
            }

            System.out.println(point.mKey);
        }
    }
}
